package homework.demo2;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@PropertySource("classpath:config.properties")
@Component
public class DBUtil {
    @Value("${spring.datasource.url}")
    private String url;
    @Value("spring.datasource.password")
    private String password;
    @Value("spring.datasource.username")
    private String username;

    @Override
    public String toString() {
        return "DBUtil{" +
                "url='" + url + '\'' +
                ", password='" + password + '\'' +
                ", username='" + username + '\'' +
                '}';
    }

    public String getUrl() {
        return url;
    }
    @Value("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true")
    public void setUrl(String url) {
        this.url = url;
    }

    public String getPassword() {
        return password;
    }
    @Value("root")
    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }
    @Value("root")
    public void setUsername(String username) {
        this.username = username;
    }
}
